package com.micro.glszh.stat.exception;

import com.micro.glszh.stat.base.HttpCodeEnum;
import lombok.Data;

/**
 * @author: gaopengfei
 * @description: 定义的基础异常
 * @version: 1.0.0
 */
@Data
public class BaseException extends RuntimeException {
    private static final int BASE_EXCEPTION_CODE = HttpCodeEnum.FAILED.getCode();
    private static final String BASE_EXCEPTION_MESSAGE = HttpCodeEnum.FAILED.getMessage();


    protected Integer code;
    protected String message;

    public BaseException() {
        super(BASE_EXCEPTION_MESSAGE);
        this.code = BASE_EXCEPTION_CODE;
        this.message = BASE_EXCEPTION_MESSAGE;
    }

    public BaseException(String message) {
        super(message);
        this.code = BASE_EXCEPTION_CODE;
        this.message = message;
    }

    public BaseException(HttpCodeEnum httpCodeEnum) {
        super(httpCodeEnum.getMessage());
        this.code = httpCodeEnum.getCode();
        this.message = httpCodeEnum.getMessage();
    }

    public BaseException(Throwable cause) {
        super(cause);
        this.code = BASE_EXCEPTION_CODE;
        this.message = BASE_EXCEPTION_MESSAGE;
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
        this.code = BASE_EXCEPTION_CODE;
        this.message = message;
    }

    public BaseException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BaseException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
    }
}
